<?php
namespace common\widgets;

use Yii;
use yii\base\InvalidConfigException;
use yii\helpers\Html;
use yii\base\Widget;
use yii\data\Pagination;
use yii\helpers\ArrayHelper;

class LinkPagerButton extends \yii\widgets\LinkPager
{
    /**
     * onclick事件
     * @var unknown
     */
    public $onclick;
	/**
	 * Renders a page button.
	 * You may override this method to customize the generation of page buttons.
	 * @param string $label the text label for the button
	 * @param int $page the page number
	 * @param string $class the CSS class for the page button.
	 * @param bool $disabled whether this page button is disabled
	 * @param bool $active whether this page button is active
	 * @return string the rendering result
	 */
	
	protected function renderPageButton($label, $page, $class, $disabled, $active)
	{
	    $options = ['class' => empty($class) ? $this->pageCssClass : $class];
	    if ($active) {
	        Html::addCssClass($options, $this->activePageCssClass);
	    }
// 	    if ($disabled) {
// 	        Html::addCssClass($options, $this->disabledPageCssClass);
// 	        $tag = ArrayHelper::remove($this->disabledListItemSubTagOptions, 'tag', 'span');
	        
// 	        return Html::tag('li', Html::tag($tag, $label, $this->disabledListItemSubTagOptions), $options);
// 	    }
	    $linkOptions = $this->linkOptions;
	    $linkOptions['data-page'] = $page;
	    if (in_array($label, ['<','>'])){
	        if ($label == '>'){
	            $label = '下一页';
	        }else{
	            $label = '上一页';
	        }
	        $page++;
	    }else{
	        $page = $label;
	        $label = $label;
	    }
	    return Html::tag('li', Html::button($label, ['onclick'=>$this->onclick.'('.$page.')']), $options);
	}
}
